#include <iostream>
#include "../common/common.h"

void summaryCPU(float *array_a, float *array_b, float *array_res, int size)
{
    for (int i = 0; i < size; i++)
        array_res[i] = array_a[i] + array_b[i];
}

int main(int argc, char **argv)
{
    int nElem = 1 << 3;
    size_t nBytes = sizeof(float) * nElem;

    // cpu申请内存并初始化数据
    float *host_array_a = (float *)malloc(nBytes);
    float *host_array_b = (float *)malloc(nBytes);
    float *host_array_res = (float *)malloc(nBytes);
    initialDataRandom(host_array_a, nElem);
    initialDataRandom(host_array_b, nElem);
    memset(host_array_res, 0, nBytes);

    // 两个数组相加
    summaryCPU(host_array_a, host_array_b, host_array_res, nElem);
    printVector(host_array_a, nElem, "host_array_a");
    printVector(host_array_b, nElem, "host_array_b");
    printVector(host_array_res, nElem, "host_array_res");

    free(host_array_a);
    free(host_array_b);
    free(host_array_res);

    return 0;
}